package com.beimihu.leetcode;


//https://leetcode.cn/problems/ransom-note/?envType=study-plan-v2&envId=top-interview-150
public class CanConstruct {
    public boolean canConstruct(String ransomNote, String magazine) {
        if(ransomNote.length() < magazine.length()){
            return false;
        }

        int[] cnt = new int[26];

        for(char c :magazine.toCharArray()){
            cnt[c - 'a'] ++;

        }
        for(char c :ransomNote.toCharArray()){
            cnt[c - 'a'] --;
            if(cnt [c - 'a'] < 0 ){
                return false;
            }
        }
        return true;
    }
}
